home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / NetMouse ƒ / NetMouse Xmt / Misc.h < prev    next >
Encoding:
Text File  |  1992-06-22  |  4.9 KB  |  172 lines  |  [TEXT/KAHL]

  1. // This code was written Thursday June 22, 1992 by Jorg 'jbx' Brown.
  2. // This code is not freeware; this code is public domain.
  3.  
  4. #pragma once
  5.  
  6. // #undef SystemSevenOrLater
  7. // #define SystemSevenOrLater 1
  8.  
  9. #include <Processes.h>
  10.  
  11. #ifdef __APPLETALK__
  12.     #include <Aliases.h>
  13. #else
  14.     #define __APPLETALK__    // suppress unnecessary #include <AppleTalk.h>
  15.     #include <Aliases.h>
  16.     #undef __APPLETALK__
  17. #endif
  18.  
  19. typedef unsigned char  uchar;
  20. typedef unsigned short ushort;
  21. typedef unsigned long  ulong;
  22.  
  23. extern struct Keyboard {
  24.     short    wasted;
  25.     short    wasted2;
  26.     short    wasted3;
  27.     int command : 1;
  28.     int : 5;
  29.     int space : 1;
  30.     int tab : 1;
  31.     int : 4;
  32.     int control : 1;
  33.     int option : 1;
  34.     int capslock : 1;
  35.     int shift : 1;
  36. } keymap : 0x174;
  37.  
  38.     // this structure is useful for interpreting the fdFlags field of the FInfo structure.
  39. typedef struct {
  40.     int isAlias        : 1;
  41.     int isInvisible : 1;
  42.     int hasBundle    : 1;
  43.     int nameLocked    : 1;
  44.     int isStationery: 1;
  45.     int hasCustomIcn: 1;
  46.     int             : 1;
  47.     int wasInited    : 1;
  48.     int hasNoINITS    : 1;
  49.     int isShared    : 1;
  50.     int SwitchLaunch: 1;
  51.     int             : 1;
  52.     int color       : 3;
  53.     int             : 1;
  54. } FileFlags;
  55.  
  56. // theQDPort() is a quick way of getting the current port without having to
  57. // call GetPort.
  58.  
  59. #pragma parameter __A0 theQDPort()
  60. pascal GrafPtr theQDPort(void) = { 0x2055, 0x2050 };
  61.  
  62. // SetA4 is an inline for setting register a4 without using inline assembly.
  63. // it returns the old value of a4.
  64.  
  65. #pragma parameter __A0 SetA4(__A0)
  66. pascal void *SetA4(void *newA4) = 0xC948;
  67.  
  68. // CopyHandle is a better interface to HandToHand.
  69.  
  70. #pragma parameter __A0 CopyHandle(__A0)
  71. pascal void *CopyHandle(void *) = {0xA9E1};
  72.  
  73. // jbGetHandleSize is just GetHandleSize, without the error checks.
  74.  
  75. #pragma parameter __D0 jbGetHandleSize(__A0)
  76. pascal Size jbGetHandleSize(void *h) = 0xA025;
  77.  
  78. // HandleOf is a better interface to PtrToHand
  79.  
  80. #pragma parameter __A0 HandleOf(__A0, __D0)
  81. pascal void *HandleOf(void *, long) = {0xA9E3};
  82.  
  83. // ClearSpace is a trivial inline for clearing space out.
  84.  
  85. #pragma parameter ClearSpace(__A0, __D0)
  86. pascal void ClearSpace(void *, long) = {0x4218, 0x5380, 0x66FA};
  87.  
  88. // QuickMove is faster than BlockMove for very small moves.
  89. // (and it doesn't clear the cache)
  90.  
  91. #pragma parameter QuickMove(__A0, __A1, __D0)
  92. pascal void QuickMove(void *from, void *to, short bytes) = {0x12D8, 0x5340, 0x66FA};
  93.  
  94. // MakeALong makes a long out of two shorts efficiently.
  95.  
  96. #pragma parameter __D0 MakeALong(__D0, __D1)
  97. pascal long MakeALong(short HiWord, short LoWord) = {0x4840, 0x3001};
  98.  
  99. // MinShort takes the minimum of two input shorts efficiently
  100.  
  101. #pragma parameter __D0 MinShort(__D0, __D1)
  102. pascal short MinShort (short a, short b) = {0xB240, 0x6E02, 0x3001};
  103.  
  104. // MaxShort takes the maximum of two input shorts efficiently
  105.  
  106. #pragma parameter __D0 MaxShort(__D0, __D1)
  107. pascal short MaxShort (short a, short b) = {0xB240, 0x6D02, 0x3001};
  108.  
  109. // jbLoWord quickly retrieves the low word of a long..
  110.  
  111. #define jbLoWord(l) ((short)(l))
  112.  
  113. // jbHiWord quickly retrieves the high word of a long..
  114.  
  115. #pragma parameter __D0 jbHiWord(__D0)
  116. pascal short jbHiWord(long Long) = {0x4840};
  117.  
  118. // jbxDelay is a better interface for Delay.
  119.  
  120. #pragma parameter __A0 jbxDelay(__A0)
  121. pascal long jbxDelay(long numTicks)
  122.     = {0xA03B}; 
  123.  
  124. // PenWhite calls PenPat(white) from QuickDraw's globals.
  125.  
  126. pascal void PenWhite(void)
  127.     =    {0x2055, 0x4868, 0xFFF8, 0xA89D};
  128.  
  129. // PenBlack calls PenPat(black) from QuickDraw's globals.
  130.  
  131. pascal void PenBlack(void)
  132.     =    {0x2055, 0x4868, 0xFFF0, 0xA89D};
  133.  
  134. // PenGray calls PenPat(gray) from QuickDraw's globals.
  135.  
  136. pascal void PenGray(void)
  137.     =    {0x2055, 0x4868, 0xFFE8, 0xA89D};
  138.  
  139. // ArrowCursor calls SetCursor(arrow) from QuickDraw's globals.
  140.  
  141. pascal void ArrowCursor(void)
  142.     =    {0x2055, 0x4868, 0xFF94, 0xA851};
  143.  
  144. // PStringMove is a quick pascal string copy using the toolbox.
  145.  
  146. #pragma parameter PStringMove(__A0,__A1)
  147. pascal void PStringMove(const void *srcPtr,void *destPtr)
  148.     = {0x7001, 0xD010, 0xA02E}; 
  149.  
  150. // Why HOpenResFile isn't declared this way, I don't know.
  151. // (Under System 7, HORF has its own trap.  MacTraps uses glue code.)
  152.  
  153. pascal short HOpenResFile7(short vRefNum,long dirID,ConstStr255Param fileName,
  154.     char permission) = 0xA81A;
  155.  
  156. // a quicker inline for access to NumToString when you need it:
  157.  
  158. #pragma parameter iNumToString(__D0, __A0)
  159. pascal void iNumToString(long theNum, void *theString) = {0x4267, 0xA9EE};
  160.  
  161. // This routine, well, we all know what this routine does.  Call ShowINIT(ID) to
  162. // show the icon with resource id ID, or call ShowINIT(0, ID) to show the icon but
  163. // not advance the drawing position.  (i.e. call ShowINIT(0, 1), ShowINIT(0, 2),
  164. // ShowINIT(0, 3), ShowINIT(4) to animate startup icons.
  165.  
  166. extern void ShowINIT(short iconID, ...);
  167.  
  168. // DrawAnIcon draws color or black and white 32x32 icons.  It takes two pointers,
  169. // one assumed to be pointing to the data found in a ICN# resource, the other pointing
  170. // to a icl4 or icl8 resource, depending on iclDepth.
  171.  
  172. extern void DrawAnIcon(void *BlackAndWhiteIcon, void *ColorIcon, short iclDepth, Rect dstRect);